package com.security.door.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.security.door.core.base.BaseService;
import com.security.door.dao.mapper.devDeviceinfoMapper;
import com.security.door.model.domain.devDeviceinfo;
import com.security.door.model.dto.devDeviceinfoDto;
import com.security.door.model.vo.deviceInfoVo;
import com.security.door.model.vo.treeViewVo;
import com.security.door.service.IdevDeviceinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class devDeviceinfoServiceImpl extends BaseService<devDeviceinfo> implements IdevDeviceinfoService {

    @Autowired
    devDeviceinfoMapper idevDeviceinfoMapper;

    @Override
    public PageInfo<deviceInfoVo> queryListWithPage(devDeviceinfoDto entity) {
        PageHelper.startPage(entity.getPageIndex(), entity.getPageSize());
        var actionList = idevDeviceinfoMapper.queryListWithPage(entity);
        return new PageInfo<deviceInfoVo>(actionList);
    }


    @Override
    public List<treeViewVo> selectAllTree() {
        return idevDeviceinfoMapper.selectAllTree();
    }

    public boolean hasExists(String deviceCode) {
        return idevDeviceinfoMapper.hasExists(deviceCode) > 0 ? true : false;
    }

    public Integer deleteByCode(String deviceCode) {
        return idevDeviceinfoMapper.deleteByCode(deviceCode);
    }

    public devDeviceinfo selectByCode(String deviceCode) {
        return idevDeviceinfoMapper.selectByCode(deviceCode);
    }

    public List<devDeviceinfo> selectTreeByAreaCode(String areaCode) {
        return idevDeviceinfoMapper.selectTreeByAreaCode(areaCode);
    }
}
